<?php

namespace app\admin\model;

use app\admin\model\BaseModel;


class SiteLog extends BaseModel
{

    protected $name = "site_log";
    protected $pk = "id";
    // 追加属性
    protected $append = ['admin_title', 'site_title'];
    protected $deleteTime = false;

    public function getAdminTitleAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['admin_id']) ? $data['admin_id'] : '');
        $admin = table('system_admin')->where(['id' => $data['admin_id']])->find();
        return isset($admin['nickname']) ? $admin['nickname'] : '';
    }

    public function getSiteTitleAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['site_id']) ? $data['site_id'] : '');
        $admin = table('site')->where(['id' => $data['site_id']])->find();
        return isset($admin['site_name']) ? $admin['site_name'] : '';
    }
}
